HAL OS Functions

OS Semaphore functions

group OS_Exported_Functions_Group1

This subsection provides a set of functions allowing to control access to shared resources using Semaphore:

Functions

hal_os_status_t HAL_OS_SemaphoreCreate ( hal_os_semaphore_t * p_sem )

Create a new binary semaphore instance.

Parameters :

p_sem – Pointer to a hal_os_semaphore_t structure.

Return values :
  • HAL_OS_OK – Semaphore instance created successfully.

  • HAL_OS_ERROR – An error occurred.

hal_os_status_t HAL_OS_SemaphoreTake ( hal_os_semaphore_t * p_sem , uint32_t timeout_ms )

Take a semaphore that was created previously.

Parameters :
  • p_sem – Pointer to a hal_os_semaphore_t structure.

  • timeout_ms – The time to wait for the semaphore to become available in ms.

Return values :
  • HAL_OS_OK – Semaphore taken successfully.

  • HAL_OS_ERROR – The timeout_ms expired without the semaphore becoming available.

hal_os_status_t HAL_OS_SemaphoreRelease ( hal_os_semaphore_t * p_sem )

Release the semaphore.

Parameters :

p_sem – Pointer to a hal_os_semaphore_t structure.

Return values :
  • HAL_OS_OK – Semaphore released successfully.

  • HAL_OS_ERROR – An error occurred.

hal_os_status_t HAL_OS_SemaphoreDelete ( hal_os_semaphore_t * p_sem )

Delete the semaphore.

Parameters :

p_sem – Pointer to a hal_os_semaphore_t structure.

Return values :
  • HAL_OS_OK – Semaphore deleted successfully.

  • HAL_OS_ERROR – An error occurred.

OS Mutex functions

group OS_Exported_Functions_Group2

This subsection provides a set of functions allowing to control access to shared resources using Mutex:

Functions

hal_os_status_t HAL_OS_MutexCreate ( hal_os_mutex_t * p_mutex )

Create a new mutex instance.

Parameters :

p_mutex – Pointer to a hal_os_mutex_t structure.

Return values :
  • HAL_OS_OK – Mutex created successfully.

  • HAL_OS_ERROR – An error occurred.

hal_os_status_t HAL_OS_MutexTake ( hal_os_mutex_t * p_mutex , uint32_t timeout_ms )

Take a mutex that was created previously.

Parameters :
  • p_mutex – Pointer to a hal_os_mutex_t structure.

  • timeout_ms – The time to wait for the mutex to become available in ms.

Return values :
  • HAL_OS_OK – Semaphore taken successfully.

  • HAL_OS_ERROR – The timeout_ms expired without the mutex becoming available.

hal_os_status_t HAL_OS_MutexRelease ( hal_os_mutex_t * p_mutex )

Release the mutex.

Parameters :

p_mutex – Pointer to a hal_os_mutex_t structure.

Return values :
  • HAL_OS_OK – Mutex released successfully.

  • HAL_OS_ERROR – An error occurred.

hal_os_status_t HAL_OS_MutexDelete ( hal_os_mutex_t * p_mutex )

Delete the mutex.

Parameters :

p_mutex – Pointer to a hal_os_mutex_t structure.

Return values :
  • HAL_OS_OK – Mutex was deleted successfully.

  • HAL_OS_ERROR – An error occurred.